package org.textreport.lang;

import java.util.ArrayList;
import java.util.List;

import org.textreport.core.ExecutionContext;

public class ExpressionList implements Expression {
	private List<Expression> list = new ArrayList<>();
	private int sourceLine;
	private boolean hasBody;
	private Expression parent;
	
	public ExpressionList(Expression parent) {
		this.parent = parent;
	}
	
	@Override
	public void eval(ExecutionContext ctx) {
		
		for(Expression e: list){
			e.eval(ctx);
		}
	}
	
	public void addBodyExpression(Expression e){
		list.add(e);
	}

	@Override
	public boolean hasBody() {
		return hasBody;
	}

	@Override
	public int getSourceLine() {
		return sourceLine;
	}

	@Override
	public void setSourceLine(int line) {
		sourceLine = line;
	}

	public void setHasBody(boolean hasBody) {
		this.hasBody = hasBody;
	}

	@Override
	public Expression getParent() {
		return parent;
	}

}
